import { confirmGet, cancelRefund } from '@/api/order.js'
import { openMechine } from '@/api/online.js'
const handle = {
  data () {
    return {
    }
  },
  computed: {
  	bluetoothObj() {
  		return this.$store.getters.bluetoothObj
  	}
  },
  methods: {
		// 申请退款退货
		afterSales(id) {
			uni.navigateTo({
			    url: `/pages/order/after-sales?orderId=${id}`
			})
		},
		
		// 填写单号
		express(id) {
			uni.navigateTo({
			    url: `/pages/order/express?orderId=${id}`
			})
		},
		
		// 物流信息
		expressInfo(expressNo) {
			uni.navigateToMiniProgram({
			  appId: 'wx6885acbedba59c14',
			  path: `pages/result/result?nu=${expressNo}&com=&querysource=third_xcx`,
			  success(res) {
			    // 打开成功
			  }
			})
		},
		
		// 取消退款退/货申请
		handleCancelRefund(refundId) {
			const that = this
			uni.showModal({
				title: '提示',
				content: '确定取消申请？',
				success: function (res) {
					if (res.confirm) {
						cancelRefund({refundId}).then(respanse => {
							that.cancelRefundCallback()
						})
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			})
		},
		
		// 确认收货
		handleConfirmGet(orderId) {
			const that = this
			uni.showModal({
				title: '提示',
				content: '确认收货？',
				success: function (res) {
					if (res.confirm) {
						confirmGet({orderId}).then(respanse => {
							that.confirmGetCallback()
						})
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			})
		},
		
		// 支付成功回调
		bluetoothCallback() {
			console.log('bl')
			const data = {
				orderNo: this.createOrderDetails.orderNo
			}
			openMechine(data).then(respanse => {
				const _Buffer = respanse.result
				this.bluetoothObj.writeDevice(_Buffer)
				this.confirmGetCallback()
			}).catch(err => {
				this.submitFlag = false
			})
		}
    }
  }
export default handle
